package models

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Name  string `gorm:"type:varchar(30)"json:"name"`
	Shou  string `gorm:"type:varchar(11)"json:"shou"`
	Ke    string `gorm:"type:varchar(11)"json:"ke"`
	Gua   string `gorm:"type:varchar(11)"json:"gua"`
	Times string `gorm:"type:varchar(30)"json:"times"`
}

func (*User) DataAdd(user *User) error {
	tx := DB.Begin()
	err := DB.Debug().Create(&user).Error
	if err != nil {
		tx.Rollback()
		return err
	}
	tx.Commit()
	return err
}
